home *** CD-ROM | disk | FTP | other *** search
- class Heroes.WorldObject extends MovieClip
- {
- var zMin;
- var zMax;
- var zdx;
- var zdy;
- var g;
- var dyMax;
- var scale;
- var windowWidth;
- var dy;
- var y;
- var z;
- var x;
- var graphics;
- var shadowY;
- var doScale;
- var hasFoundShadow = false;
- var isGrabbed = false;
- function WorldObject()
- {
- super();
- this.zMin = 0;
- this.zMax = 350;
- this.zdx = 0;
- this.zdy = 0.6;
- this.g = -1.5;
- this.dyMax = -20;
- this.scale = 1.3;
- this.windowWidth = 470;
- this.dy = 0;
- if(this.y == -1)
- {
- this.y = 0;
- }
- if(this.z == -1)
- {
- this.z = int((400 - this.y - this._y) / this.zdy);
- }
- if(this.x == -1)
- {
- this.x = int(this._x - this.z * this.zdx);
- }
- this._visible = false;
- }
- function onEnterFrame()
- {
- if(this._visible)
- {
- this.limitZ();
- this.fall();
- this.updatePosition();
- this._parent.updateDepth(this,Math.round(400 - this.z));
- if(this.hasFoundShadow)
- {
- this.graphics.shadow._y = this.shadowY + this.y;
- }
- else if(typeof this.graphics.shadow == "movieclip")
- {
- this.hasFoundShadow = true;
- this.shadowY = this.graphics.shadow._y;
- }
- }
- }
- function fall()
- {
- if(!this.isGrabbed)
- {
- this.dy += this.g;
- if(this.dy < this.dyMax)
- {
- this.dy = this.dyMax;
- }
- this.y += this.dy;
- if(this.y < 0)
- {
- this.y = 0;
- this.dy = 0;
- }
- }
- }
- function limitZ()
- {
- if(this.z < this.zMin)
- {
- this.z = this.zMin;
- }
- if(this.z > this.zMax)
- {
- this.z = this.zMax;
- }
- }
- function get_X(testX, testZ)
- {
- return testX + testZ * this.zdx;
- }
- function get_Y(testY, testZ)
- {
- return 400 - testY - testZ * this.zdy;
- }
- function isOnScreen()
- {
- return this.isXOnScreen(this.x);
- }
- function isXOnScreen(testX)
- {
- var _loc2_ = this._width / 2;
- return testX + _loc2_ > - this._parent._x - 30 && testX - _loc2_ < - this._parent._x + 500;
- }
- function updatePosition()
- {
- var _loc2_ = this.scale + (this.scale - 1) * this.z / -400;
- if(this.doScale)
- {
- this._xscale = 100 * _loc2_;
- this._yscale = 100 * _loc2_;
- }
- var _loc3_ = _loc2_ * (this.x + this._parent._x - this.windowWidth / 2);
- this._x = _loc3_ - this._parent._x + this.windowWidth / 2;
- this._y = 160000 / (this.z + 400);
- if(this.z > 218)
- {
- this._y -= 3;
- }
- }
- function calculateZ(ypos)
- {
- return 160000 / ypos - 400;
- }
- function playSound(soundName)
- {
- if(this._visible && (this._name == "player" || this._parent.player.intelligence > 0 && this._parent._parent.timer.getTime() > 0))
- {
- var _loc2_ = this._x + this._parent._x;
- pi.AudioLibrary.setPan(soundName,Math.round((_loc2_ - 235) / 4));
- pi.AudioLibrary.playSound(soundName,1);
- }
- }
- }
-